    var customIcons = {
      station: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      },
      bar: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      }
    };
    
    function bindInfoWindow(marker, map, infoWindow, html) {
        google.maps.event.addListener(marker, 'click', function() {
          infoWindow.setContent(html);
          infoWindow.open(map, marker);
        });
      }
    
    function load(lat, lng) {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(lat, lng),
        zoom: 13,
        mapTypeId: 'roadmap'
      });
      var infoWindow = new google.maps.InfoWindow;

      // Change this depending on the name of your PHP file
      downloadUrl("phpsqlajax_genxml.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var country = markers[i].getAttribute("country");
          var type = markers[i].getAttribute("type");
          var stn = markers[i].getAttribute("stn");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("lat")),
              parseFloat(markers[i].getAttribute("lng")));
          var html = "<b>" + name + "</b> <br/>" + country
          + "<br/>Station number: " + stn
          	+ "<br/>Latitude: " + markers[i].getAttribute("lat")
          	+ "<br/>Longitude: " + markers[i].getAttribute("lng") + "<br/>" +
	          '<a href="#" target="_blank" onclick="Popup=window.open(\'inc/graphframe.inc.php?stn='+ stn + '\',\'Popup\',\'toolbar=no,' +
	        	  'location=no,status=no,menubar=no,scrollbars=no,resizable=no, width=450,height=350,left=430,top=23\'); return false;">' +
	        	  'View graph of current cloud coverage</a>';
          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon,
            shadow: icon.shadow
          });
  
          
          
          bindInfoWindow(marker, map, infoWindow, html);
        }
      });
    }
    
    function relocate(lat,lng){ 
    	var newlocation = new google.maps.LatLng(lat,lng);
    	map.panTo(newlocation); 	
    } 

  

    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }

    function doNothing() {}